<template>
  <div id="client">
    <div class="client-top" style="">
      <p style="margin-left: 20px">
        <span class="demonstration">单据日期：</span>
        <el-date-picker
        v-model="quotation.ddate"
          type="datetime"
          placeholder="选择日期时间"
          default-time="12:00:00"
        >
        </el-date-picker>
        &nbsp;&nbsp; 报价类型：
        <el-select placeholder="报价类型" style="width: 100px"  v-model="quotation.dtype">
          <el-option
            v-for="item in baojiatype"
            :key="item.value"
            :label="item.lable"
            :value="item.value"
          >
          </el-option> </el-select
        >&nbsp;&nbsp; 报价主体：
        <el-select
          placeholder="报价主体"
          style="width: 100px"
          v-model="quotation.dentity"
        >
          <el-option
            v-for="item in baojiabody"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option> </el-select
        >&nbsp;&nbsp; 业务员：
        <el-select placeholder="业务员" style="width: 100px"  v-model="quotation.saleser">
          <el-option
            v-for="item in doman"
            :key="item.domanid"
            :label="item.label"
            :value="item.domanid"
          >
          </el-option>
        </el-select>
      </p>
      <p style="margin-top: 20px; margin-left: 20px">
        &nbsp;&nbsp;
        <span class="demonstration" style="margin-left: 20px">有效日期：</span>
        <el-date-picker
          type="daterange"
          v-model="effectiveDateRange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
        >
        </el-date-picker>
        <span
          style="
            display: inline-block;
            float: right;
            position: relative;
            right: 100px;
          "
        >
        <el-button v-if="isOk">新增</el-button>&nbsp;&nbsp;
          <el-button type="primary" @click="save()" >保存</el-button>&nbsp;&nbsp;
          <el-button type="primary" @click="verse()" v-if="isVese">审核</el-button>&nbsp;&nbsp;
          <el-button v-if="isFvers">反审核</el-button>&nbsp;&nbsp;
          <el-button v-if="isFvers">生成销货订单</el-button>&nbsp;&nbsp;
          <el-button v-if="isFvers">生成销货单</el-button>&nbsp;&nbsp;
          
          <i
            class="el-icon-paperclip"
            style="color: blue; margin-left: 40px"
          ></i>
          <sapn style="color: blue">上传附件</sapn>
        </span>
      </p>
    </div>
    <div class="client-content" style="margin-top: 10px">
      <el-divider></el-divider>
      <div style="margin-top: 30px">
        <el-table
          height="300px"
          :data="tableData"
          border
          style="width: 100%; font-size: 13px"
        >
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column fixed prop="date" label="商品" width="230">
            <el-input
              style="width: 120px; margin-left: 10px; margin-right: 20px"
              placeholder="请输入商品"
              clearable
            ></el-input>
            <el-button
              style="margin-left: -20px; margin-right: 10px; width: 50px"
              @click="dialogFormVisible = true"
              >...</el-button
            >
          </el-table-column>
          <el-table-column prop="name" label="商品名称" width="120">
          </el-table-column>
          <el-table-column prop="picture" label="图片" width="120">
          </el-table-column>
          <el-table-column prop="jd" label="基本单位" width="120">
          </el-table-column>
          <el-table-column prop="num" label="基本数量" width="120">
          </el-table-column>
          <el-table-column prop="ck" label="仓库" width="120">
          </el-table-column>
          <el-table-column prop="initPrice" label="报价单价" width="120">
          </el-table-column>
          <el-table-column prop="taxedPrice" label="折后含税单价" width="120">
          </el-table-column>
          <el-table-column prop="discount" label="折扣率" width="120">
          </el-table-column>
          <el-table-column prop="tax" label="税率" width="120">
          </el-table-column>
          <el-table-column prop="lastPrice" label="价税合计" width="120">
          </el-table-column>
          <el-table-column prop="text" label="备注" width="120">
          </el-table-column>
        </el-table>
        <div
          style="width: 100%; background-color: blanchedalmond; height: 30px"
        >
          <table style="width: 78.7%; height: 30px">
            <tr>
              <td style="width: 50%">合计：</td>
              <td style="width: 50%">123</td>
            </tr>
          </table>
        </div>
        <el-input
          type="textarea"
          :rows="2"
          placeholder="暂无备注信息"
          style="width: 100%; line-height: 20px"
        >
        </el-input>
        <div style="float: right; margin-right: 20px; margin-top: 10px">
          <p>
            交货方式：
            <el-select
            v-model="quotation.dmethod"
              placeholder="交货方式"
              style="width: 100px"
            >
              <el-option
                v-for="item in jiaohuo"
                :key="item.id"
                :label="item.label"
                :value="item.id"
              >
              </el-option> </el-select
            >&nbsp;&nbsp; 
          </p>
          <p style="margin-top: 20px">
            <el-button type="primary" @click="goto('quoteList')"
              >历史单据</el-button
            >&nbsp;&nbsp; <el-button type="primary">操作日志</el-button>
          </p>
        </div>
      </div>
      <el-dialog top="20px" title="选择商品" :visible.sync="dialogFormVisible">
        <el-input
          placeholder="请输入编号或名称"
          style="width: 200px; margin-left: 20px"
        ></el-input
        >&nbsp;&nbsp; 仓库：<el-select
          placeholder="请选择"
          style="width: 100px"
        >
          <el-option
            v-for="item in ck"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
        <el-checkbox style="margin-left: 20px"
          >显示禁用商品</el-checkbox
        >
        <el-button type="success" style="margin-left: 20px">查询</el-button>
        <el-table :data="gridData">
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column width="100" label="图片"></el-table-column>
          <el-table-column
            width="100"
            property="goodsId"
            label="商品编号"
          ></el-table-column>
          <el-table-column
            width="300"
            property="address"
            label="产地"
          ></el-table-column>
          <el-table-column
            width="100"
            property="property"
            label="辅助属性编号"
          ></el-table-column>
          <el-table-column
            width="100"
            property="name"
            label="商品名称"
          ></el-table-column>
          <el-table-column
            width="100"
            property="model"
            label="规格型号"
          ></el-table-column>
          <el-table-column
            width="100"
            property="type"
            label="商品类别"
          ></el-table-column>
          <el-table-column
            width="100"
            property="danwei"
            label="单位"
          ></el-table-column>
          <el-table-column
            width="100"
            property="kc"
            label="库存"
          ></el-table-column>
          <el-table-column
            width="100"
            property="text"
            label="备注"
          ></el-table-column>
        </el-table>
        <div class="block">
          <span class="demonstration"></span>
          <el-pagination layout="prev, pager, next" :total="1000">
          </el-pagination>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogFormVisible = false"
            >确 定</el-button
          >
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  name: "Quote",
  data() {
    return {
      isOk:false,
      isLook:false,
      isVese:true,
      isFvers:false,
      effectiveDateRange:[],
             quotation:{
              ddate:'',
              dentity:'2424',
              dnum:'454542',
              dtype:'24424',
              dstatus:0,
              vstatus:0,
              qstartTime:'',
              qendTime:'',
              saleser:'4242',
              dmethod:5,
              quantity:3,
              amount:555,
              prepared:'727272',
              reviewer:'151215'
             }

    }
  },
  methods: {
    goto(to) {
      this.$router.push(to);
    },
    save(){
         this.quotation.qstartTime=this.effectiveDateRange[0]
    alert(this.effectiveDateRange[0])
    this.quotation.qendTime=this.effectiveDateRange[1]
    console.log(this.quotation)
      this.axios({
             url:'/quote/add',
             method:'post',
             data:{
              ...this.quotation
             }
      }).then(rs=>{
        if(rs.data.isAdd=true){
          alert("增加成功")
          this.isOk=true;
        }else{
          alert("增加失败")
        }
      })
    },
     verse(){
    alert("审核成功")
    this.isVese=false;
   this.isFvers=true;
  }
  },
 
};
</script>

<style scoped>
.el-button el-button--default el-popover__reference {
  margin-right: 20px;
}

tr {
  border: 1px solid black;
}
</style>